package net.ezsteam;

import net.ezsteam.cons.EzSteam_Urls;
import net.ezsteam.service.EzSteam_GetCars_Service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;


public class EzSteam_MyProfile_Activity extends Activity {
	
	private String customerid="";
	private String user;
	private String email;
	private String password;
	private ListView listview;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ezsteam_profile);
		
		Bundle extras = getIntent().getExtras();

		if (extras != null) {
			String cusid = extras.getString("cusid");
			user = extras.getString("user");
			email = extras.getString("email");
			password = extras.getString("password");
			customerid  = cusid;
			
			TextView txt_username = (TextView)findViewById(R.id.txt_username);
			TextView txt_email = (TextView)findViewById(R.id.txt_email);
			
			txt_username.setText(user);
			txt_email.setText(email);
		}
		
		Button btnEdit = (Button)findViewById(R.id.btn_edit);
		btnEdit.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(EzSteam_MyProfile_Activity.this,EzSteam_MyProfile_Edit_Activity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				Bundle bundle = new Bundle();
				bundle.putString("cusid", customerid);
				bundle.putString("name", user);
				bundle.putString("email", email);
				bundle.putString("password", password);
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});
		
		listview = (ListView) findViewById(R.id.list_cars);
		
		/*EzSteam_GetCars_Service eas = new EzSteam_GetCars_Service(EzSteam_MyProfile_Activity.this,listview);
		eas.execute(EzSteam_Urls.GetCar_Service+"/"+customerid.trim());*/
		
		//eas.execute(EzSteam_Urls.GetCar_Service+"/23");
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		EzSteam_GetCars_Service eas = new EzSteam_GetCars_Service(EzSteam_MyProfile_Activity.this,listview);
		eas.execute(EzSteam_Urls.GetCar_Service+"/"+customerid.trim());
	}
}
